import type { FamilyForm, FamilyQuery, FamilyVO } from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询客户家庭组列表
 * @param params
 * @returns 客户家庭组列表
 */
export function familyList(params?: FamilyQuery) {
  return requestClient.get<PageResult<FamilyVO>>('/hm/family/list', { params });
}

/**
 * 导出客户家庭组列表
 * @param params
 * @returns 客户家庭组列表
 */
export function familyExport(params?: FamilyQuery) {
  return commonExport('/hm/family/export', params ?? {});
}

/**
 * 查询客户家庭组详情
 * @param familyId id
 * @returns 客户家庭组详情
 */
export function familyInfo(familyId: ID) {
  return requestClient.get<FamilyVO>(`/hm/family/${familyId}`);
}

/**
 * 新增客户家庭组
 * @param data
 * @returns void
 */
export function familyAdd(data: FamilyForm) {
  return requestClient.postWithMsg<void>('/hm/family', data);
}

/**
 * 更新客户家庭组
 * @param data
 * @returns void
 */
export function familyUpdate(data: FamilyForm) {
  return requestClient.putWithMsg<void>('/hm/family', data);
}

/**
 * 删除客户家庭组
 * @param familyId id
 * @returns void
 */
export function familyRemove(familyId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/hm/family/${familyId}`);
}
